/**
 * Created by admin on 2018/7/27.
 */
import post from '../post/post-proxy'

export default {
  /**
   * 登入
   * @param loginName
   * @param pwd
   * @param type
   * @returns {Promise}
   */
  loginPost: (loginName, pwd, type) => {
    return post('oauth', '/fjxhx/gis/system/login', {
      'loginName': loginName,
      'password': pwd,
      'type': type
    })
  },
  anchorTypeQuery: (page, pageSize) => {
    return post('outer', '/fjxhx/gis/anchor/type/quern', {
      'page': page,
      'pageSize': pageSize
    })
  },
  /**
   * 根据四个经纬度、地图模型、地图比例尺、锚点条件、获取锚点信息列表(cme)
   拖动前和拖动后起始经纬度、结束经纬度，是否为2d地图不能为空，现有的地图比例尺不为空，
   可为空元素：锚点类型id，比例尺，是否显示未编辑，是否显示未关联）
   若只传now不传old则获取矩形
   * @param actualMapScale
   * @param anchorTypeId
   * @param isMapModel2d
   * @param isShowNotEdit
   * @param isShowNotRelation
   * @param mapScaleList
   * @param nowLatitudeEnd
   * @param nowLatitudeStart
   * @param nowLongitudeEnd
   * @param nowLongitudeStart
   * @param oldLatitudeEnd
   * @param oldLatitudeStart
   * @param oldLongitudeEnd
   * @param oldLongitudeStart
   * @param page
   * @param pageSize
   * @returns {Promise}
   */
  getPointList: ({actualMapScale, anchorTypeId, isMapModel2d, isShowNotEdit, isShowNotRelation, mapScaleList, nowLatitudeEnd, nowLatitudeStart, nowLongitudeEnd, nowLongitudeStart, oldLatitudeEnd, oldLatitudeStart, oldLongitudeEnd, oldLongitudeStart, page, pageSize}) => {
    let params = {
      'actualMapScale': actualMapScale,
      'isMapModel2d': isMapModel2d,
      'nowLatitudeEnd': nowLatitudeEnd,
      'nowLatitudeStart': nowLatitudeStart,
      'nowLongitudeEnd': nowLongitudeEnd,
      'nowLongitudeStart': nowLongitudeStart
    }
    if (anchorTypeId) {
      params.anchorTypeId = anchorTypeId
    }
    if (isShowNotEdit) {
      params.isShowNotEdit = isShowNotEdit
    }
    if (isShowNotRelation) {
      params.isShowNotRelation = isShowNotRelation
    }
    if (mapScaleList) {
      params.mapScaleList = mapScaleList
    }
    if (oldLatitudeEnd) {
      params.oldLatitudeEnd = oldLatitudeEnd
    }
    if (oldLatitudeStart) {
      params.oldLatitudeStart = oldLatitudeStart
    }
    if (oldLongitudeEnd) {
      params.oldLongitudeEnd = oldLongitudeEnd
    }
    if (oldLongitudeStart) {
      params.oldLongitudeStart = oldLongitudeStart
    }
    if (page) {
      params.page = page
    }
    if (pageSize) {
      params.pageSize = pageSize
    }
    return post('outer', '/fjxhx/gis/anchor/more/list/get', params)
  },
  /**
   * 获取中心点列表
   * @param isDefault
   * @param page
   * @param pageSize
   * @returns {Promise}
   */
  getMapCenterList: ({isDefault, page, pageSize}) => {
    let params = {}
    if (isDefault) {
      params.isDefault = isDefault
    }
    if (page) {
      params.page = page
    }
    if (pageSize) {
      params.pageSize = pageSize
    }
    return post('outer', '/fjxhx/gis/map/center/list/get', params)
  },
  /**
   * 根据获取锚点类型2D列表
   * @returns {Promise}
   */
  getAnchorType2DList: () => {
    let params = {}
    return post('outer', '/fjxhx/gis/anchor/type/2d/list/get', params)
  },
  /**
   * 根据获取锚点类型3D列表
   * @returns {Promise}
   */
  getAnchorType3DList: () => {
    let params = {}
    return post('outer', '/fjxhx/gis/anchor/type/3d/list/get', params)
  },
  /**
   * 获取锚点详情
   * @param anchorId
   * @returns {Promise}
   */
  getPointDetail: ({anchorId}) => {
    let params = {
      'anchorId': anchorId
    }
    return post('outer', '/fjxhx/gis/anchor/get', params)
  },
  /**
   * 根据锚点类型id查找详细信息
   * @param anchorTypeId
   * @returns {Promise}
   */
  getTypeDetail: ({anchorTypeId}) => {
    let params = {
      'anchorTypeId': anchorTypeId
    }
    return post('outer', '/fjxhx/gis/anchor/type/get', params)
  },
  /**
   * 数据字典明细列表(author:qiuyanping)获取比例尺
   * @param dictCode
   */
  getScaleList: ({dictCode}) => {
    let params = {
      'dictCode': dictCode
    }
    return post('outer', '/fjxhx/gis/dict/detail/list/get', params)
  }
}
